package suit.ui.themes;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

import suit.ui.Color;
import suit.ui.Gradient;
import suit.ui.Rectangle;
import suit.ui.Theme;
import suit.ui.Widget;

public class DefaultTheme extends Theme {

	public Color background = new Color(0x000000);
	public Color borderActive = new Color(0x26B3F7);
	public Color borderInactive = new Color(0x444444);

	public Color backgroundInput = new Color(0xFFFFFF);

	public Gradient backgroundActive = new Gradient(new Color(0x2582AF),
			new Color(0x0972A5));
	public Gradient backgroundInactive = new Gradient(new Color(0x404040),
			new Color(0x242424));

	public Color labelTextColor = new Color(0xFFFFFF);
	public Font labelTextFont = Font.getFont(Font.FACE_PROPORTIONAL,
			Font.STYLE_PLAIN, Font.SIZE_LARGE);

	public Color entryTextColor = new Color(0x000000);
	public Font entryTextFont = Font.getFont(Font.FACE_PROPORTIONAL,
			Font.STYLE_PLAIN, Font.SIZE_LARGE);

	public void drawButton(Graphics g, Widget object, Rectangle allocation,
			boolean active) {
		if (active) {
			backgroundActive.paint(g, allocation, Gradient.Vert);
			g.setColor(borderActive.value());
		} else {
			backgroundInactive.paint(g, allocation, Gradient.Vert);
			g.setColor(borderInactive.value());
		}
		g.drawRect(allocation.x, allocation.y, allocation.w - 1,
				allocation.h - 1);

	}

	public void drawEntry(Graphics g, Widget object, Rectangle allocation) {

		// Back of the widget
		g.setColor(backgroundInput.value());
		g.fillRect(allocation.x, allocation.y, allocation.w, allocation.h);

		// Highlight
		new Gradient(backgroundInput.blend(new Color(0x000000), 0.25),
				backgroundInput).paint(g, new Rectangle(allocation.x,
				allocation.y, allocation.w, 10), Gradient.Vert);

		// Border
		g.setColor(borderInactive.value());
		g.drawRect(allocation.x, allocation.y, allocation.w, allocation.h);
	}

	public void setEntryText(Graphics g) {
		g.setColor(entryTextColor.value());
		g.setFont(entryTextFont);
	}

	public void setLabelText(Graphics g) {
		g.setColor(labelTextColor.value());
		g.setFont(labelTextFont);
	}

	public Font getEntryTextFont() {
		return entryTextFont;
	}

	public Font getLabelTextFont() {
		return labelTextFont;
	}

	public void drawProgressBar(Graphics g, Widget object, Rectangle allocation) {
		// Filled portion
		backgroundActive.paint(g, new Rectangle(allocation.x+1, allocation.y+1, allocation.w-1, allocation.h-1), Gradient.Vert);
		g.setColor(borderActive.value());
		g.drawLine(allocation.x + allocation.w,
				allocation.y, allocation.x + allocation.w,
				allocation.y + allocation.h - 1);
		
	}

	public void drawProgressBorder(Graphics g, Widget object,
			Rectangle allocation) {
		g.setColor(background.value());
		g.fillRect(allocation.x, allocation.y, allocation.w - 1,
				allocation.h - 1);
		
		// Widget border
		g.setColor(borderActive.value());
		g.drawRect(allocation.x, allocation.y, allocation.w,
				allocation.h);
		
	}

	public void drawListItem(Graphics g, Widget object, Rectangle allocation,
			boolean active) {
		if( active ) {
			backgroundActive.paint(g, allocation, Gradient.Vert);
		}
	}
	
}